package com.yun.zf.common.esIndex;

import lombok.Data;
import org.elasticsearch.search.suggest.completion.context.ContextMapping;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import org.springframework.data.elasticsearch.core.completion.Completion;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;

import java.math.BigDecimal;
import java.util.List;

/**
 * 小区Es 模板
 */
@Data
@Document(indexName = "community_index", shards = 1, replicas = 0)
public class CommunityIndexTemplate {
    @Id
    private Long cid;
    @Field(type = FieldType.Text,analyzer = "ik_smart",searchAnalyzer = "ik_smart")
    private String communityName;
    @Field(type = FieldType.Long)
    private Long provinceCode;
    @Field(type = FieldType.Long)
    private Long cityCode;
    @Field(type = FieldType.Long)
    private  Long regionCode;
    @Field(type = FieldType.Text,analyzer = "ik_smart",searchAnalyzer = "ik_smart")
    private  String regionName;
    @Field(type = FieldType.Text,analyzer = "ik_smart",searchAnalyzer = "ik_smart")
    private  String streetName;
    @Field(type = FieldType.Long)
    private Long streetCode;
    @Field(type = FieldType.Integer)
    private  int ctyBuildYear;
    @Field(type = FieldType.Double)
    private BigDecimal averagePrice;
    @CompletionField( maxInputLength = 100,analyzer="ik_smart",searchAnalyzer = "ik_smart"
            ,contexts ={
            @CompletionContext(name = "city", type = ContextMapping.Type.CATEGORY)
    } )
    private Completion communityNameSuggest;

    // 小区经纬度
    @GeoPointField
    private GeoPoint point;

    @Field(type = FieldType.Keyword)
    private List<String> communityStations;

    @Field(type = FieldType.Keyword)
    private List<String>  eduSchools;
    @Field(type = FieldType.Keyword)
    private List<String> business;
}
